﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddCompany.aspx.cs" Inherits="Admin_AddCompany"
    MasterPageFile="~/Site.master" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<br/>
     <asp:HyperLink ID="AdminCompaniesLink1" NavigateUrl="../Admin/Admin.aspx" runat="server">Администраторская панель</asp:HyperLink>
&nbsp; →&nbsp;
    <asp:HyperLink ID="AdminCompaniesLink2" NavigateUrl="../Admin/Companies.aspx" runat="server">База предприятий</asp:HyperLink>
&nbsp; →&nbsp;
    <b><asp:Label ID="AdminCompaniesLabel1"  runat="server" ForeColor="black" Text="">Добавление/Редактирование нового предприятия</asp:Label></b>
    <br/>
    <br />
    <table>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="Название"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CompanyName" runat="server" MaxLength="50"></asp:TextBox>
                 <asp:RequiredFieldValidator ID="CompanyNameRequired" runat="server" ControlToValidate="CompanyName"
                    CssClass="failureNotification" ToolTip="Company name is not valid" Visible="true"
                    ValidationGroup="RegisterCompanyValidationGroup">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator runat="server" ID="CompanyNameRequired2" 
                    ControlToValidate="CompanyName" Text="Введите название от 2 до 50 символов" 
                    ForeColor="Red" ValidationExpression="^([a-zA-ZА-ЯЁа-яё0-9 '-_&,().]{2,50})+$" 
                    ValidationGroup="RegisterCompanyValidationGroup" ToolTip="От 2 до 50 символов"/>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label2" runat="server" Text="Дата создания"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="CreationDate" runat="server" ToolTip="DD/MM/YYYY"></asp:TextBox>
                <asp:RequiredFieldValidator ID="CreationFieldValidator1" runat="server" ControlToValidate="CreationDate"
                    CssClass="failureNotification" ToolTip="Datatime is not valid" Visible="true"
                    ValidationGroup="RegisterCompanyValidationGroup">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1" ControlToValidate="CreationDate" Text="Введите в формате DD/MM/YYYY" ForeColor="Red" ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d" ValidationGroup="RegisterCompanyValidationGroup"/>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label3" runat="server" Text="Организационная форма"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="FormList" runat="server" 
                    DataSourceID="SqlDataSourceForm" DataTextField="Name" 
                    DataValueField="CompanyOrganizationalFormId">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceForm" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>" 
                    SelectCommand="SELECT [Name], [CompanyOrganizationalFormId] FROM [OrganizationalForm]">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label4" runat="server" Text="Вид деятельности"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ActivityList" runat="server" 
                    DataSourceID="SqlDataSourceActivity" DataTextField="Name" 
                    DataValueField="CompanyActivityId">
                </asp:DropDownList>
                
            </td><asp:SqlDataSource ID="SqlDataSourceActivity" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>" 
                    SelectCommand="SELECT [Name], [CompanyActivityId] FROM [Activity] ORDER BY Name">
                </asp:SqlDataSource>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label5" runat="server" Text="Размер"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="SizeList" runat="server" 
                    DataSourceID="SqlDataSourceSize" DataTextField="Name" 
                    DataValueField="CompanySizeId">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceSize" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>" 
                    SelectCommand="SELECT [Name], [CompanySizeId] FROM [CompanySize]">
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
    <br />
    <asp:Button ID="AddCompany" runat="server"  ValidationGroup="RegisterCompanyValidationGroup" Text="Добавить" 
        onclick="AddCompany_Click" />
    <asp:Label ID="ErrorLabel" runat="server" Text="" ForeColor="Red"></asp:Label>
</asp:Content>
